<?php

/***  DOCUMENTATION LAYER

Last Update: Sep 2007
	
DESCRIPTION
	concept test of ceo module (testing scope)
	
NOTES
	3 sections to edit below:
		1. Meta Data
		2. Procedure Block
		3. Function
	
***/

/* -- EDIT THIS SECTION ----------------------------------------------------- */
// Some Meta Data
$page_title = 'Ceo Test';
$test_name = 'Module 1';
$run_procedure = 1;

// Include Files
#require_once('path/fname.php');

/* -- END SECTION ----------------------------------------------------------- */



/* -- NO EDIT --------------------------------------------------------------- */
// Timer
$_tx0 = microtime();
// HEADER
$buffer = "<h1 style='margin:8px 0 0;'>$page_title</h1>";
$buffer .= "<h4 style='margin:0 0 16px;'>$test_name</h4>";	// put script name here
/* -- END SECTION ----------------------------------------------------------- */



/* -- EDIT THIS SECTION ----------------------------------------------------- */

// load module function
function load_module($mod_path, $MOD_ARG = null)
{
  if ( !empty($MOD_ARG) && !is_array($MOD_ARG) )
  {
    $MOD_ARG = array( $MOD_ARG );
    trigger_error('load module argument is scalar -- should be an array');
  }
  
  require_once($mod_path);
  return $ModReturn;
}


if ( $run_procedure ) 
{
	$buffer .= "<h4 style='margin:0; color:blue;'>Testing in Progess</h4>";
	
	// add code below
  $ARGS = array( 'value to be returned' );
  $Return_Data = load_module('module.inc.php', $ARGS);
  
  // results
  $arg_scope = ( isset($MOD_ARG) ) ? 'global' : 'modular';
  $inner_mod_scope = ( isset($ModReturn) ) ? 'global' : 'modular';
  
  // output
  $buffer .= 'the arguments for load_module are: ' . print_r($ARGS,1) . '<br>';
  $buffer .= 'scope of $MOD_ARG: ' . $arg_scope . '<br>';
  $buffer .= 'scope of $ModReturn: ' . $inner_mod_scope . '<br>';
  $buffer .= '$ModReturn: ' . $Mod_Return . '<br>';
  $buffer .= '$Return_Data: ' . $Return_Data . '<br>';
}

/* -- END SECTION ----------------------------------------------------------- */



/* -- NO EDITING NEEDED BELOW THIS LINE-------------------------------------- */
// output page

// Footer
$_txn = microtime();
$stx = number_format(((substr($_txn,0,9)) + (substr($_txn,-10)) - (substr($_tx0,0,9)) - (substr($_tx0,-10))),4); 
$footer = <<<HTML
<h4 style="margin:0; position:absolute; top:6px; right:6px; font-family:monospace; color:#36f; padding:4px; border:1px solid #36f; font-weight:normal; background:#f3f6ff;">
script completed in $stx s
</h4>
HTML;
$buffer .= $footer;

// Dump Html
$html = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>PHP Test: $page_title</title>
</head>
<body>
$buffer
</body>
</html>
HTML;

echo $html;

?>
